getDate(1)
getDate(2)
$(".income_navTop>span").on("click",function(){
	$(".income_navTop>span").removeClass("active");
	$(this).addClass("active");
	$(".income_navCont").css("display","none");
	$(".income_navCont").eq($(this).index()).css("display","block")
	// getDate(parseInt($(this).index())+1)
})
if($(window).width()<375){
	for (var i = 0; i < $(".ContLeft").length; i++) {
		if($(".ContLeft").eq(i).find("h4").html().length>14){
			$(".ContLeft").eq(i).find("h4").html($(".ContLeft").eq(i).find("h4").html().slice(0,13)+"...")
		}
	}
}
console.log(localStorage.uuid)
if(localStorage.logintoken){
	getDate(1)
}else{
	getDateUser(1)
}


function getDate(type){
	//获取数据
	if(true){//isNetConnected()判断是否有网
		$.ajax({
			method:"GET",
			async:true,
			url:"http://120.76.201.26:8088/bill/income",
			data:{
				uuid:localStorage.uuid,
				vid:localStorage.vid
			},
			beforeSend: function(request) {
		        request.setRequestHeader("Authorization","Basic"+localStorage.logintoken);
		    },
			success:function(e){
				console.log(e)
				if(type==1){
					var typeTitle="元"
				}else{
					var typeTitle="元"
				}
				$(".income_details").find("div").eq(0).find("h2").html(e.data.yes_total_coins)
				$(".income_details").find("div").eq(1).find("h2").html(e.data.current_balance)
				$(".income_details>span>i").html(e.data.covert_desc+"元")
				console.log(e.data.bill_info.length)
				if(e.data.bill_info.length>0){
					$(".income_navCont").eq(parseInt(type)-1).empty()
					for(var i=0;i<e.data.bill_info.length;i++){
						if(e.data.bill_info[i].type==1){
							e.data.bill_info[i].coin_nums="+"+e.data.bill_info[i].coin_nums	
						}else{
							e.data.bill_info[i].coin_nums="-"+e.data.bill_info[i].coin_nums;
						}
						var html='<div><div class="income_ContLeft"><h2>'+e.data.bill_info[i].title+'</h2><h4>'+e.data.bill_info[i].remark+'</h4></div><div class="income_ContRight"><h2>'+parseFloat(e.data.bill_info[i].reward_rmb)+typeTitle+'</h2><h4>'+e.data.bill_info[i].create_time+'</i></h4></div></div>'
						$(".income_navCont").eq(parseInt(type)-1).append(html)
					}
					$(".incomeNo").css("display","none");
					$(".income_navCont").eq(parseInt(type)-1).append("<p>系统只保留最近三天的收入明细</p>")
				}else{
					$(".income_navCont").eq(parseInt(type)-1).find("div").remove()
					$(".incomeNo").css("display","block");
					$(".income_details").find("div").eq(0).find("h2").html(0)
					$(".income_details").find("div").eq(1).find("h2").html(0)
					$(".income_details>span>i").html("0=0元")
				}
			},error:function(a){
				
			}
		})
	}else{
		$(".nullNet").css("display","block");
		$(".title").css("display","none");
		$("footer").css("display","none");
		$(".lineTitle").css("display","none");
		$(".cont_title").css("display","none");
	}
}


function getDateUser(type){
	//获取数据
	if(true){//isNetConnected()判断是否有网
		$.ajax({
			method:"GET",
			async:true,
			url:"http://120.76.201.26:8088/bill/income",
			data:{
				uuid:localStorage.uuid,
				vid:localStorage.vid
			},
			success:function(e){
				console.log(e)
				if(type==1){
					var typeTitle="元"
				}else{
					var typeTitle="元"
				}
				$(".income_details").find("div").eq(0).find("h2").html(e.data.yes_total_coins)
				$(".income_details").find("div").eq(1).find("h2").html(e.data.current_balance)
				$(".income_details>span>i").html(e.data.covert_desc+"元")
				console.log(e.data.bill_info.length)
				if(e.data.bill_info.length>0){
					$(".income_navCont").eq(parseInt(type)-1).empty()
					for(var i=0;i<e.data.bill_info.length;i++){
						if(e.data.bill_info[i].type==1){
							e.data.bill_info[i].coin_nums="+"+e.data.bill_info[i].coin_nums	
						}else{
							e.data.bill_info[i].coin_nums="-"+e.data.bill_info[i].coin_nums;
						}
						var html='<div><div class="income_ContLeft"><h2>'+e.data.bill_info[i].title+'</h2><h4>'+e.data.bill_info[i].remark+'</h4></div><div class="income_ContRight"><h2>'+parseFloat(e.data.bill_info[i].reward_rmb)+typeTitle+'</h2><h4>'+e.data.bill_info[i].create_time+'</i></h4></div></div>'
						$(".income_navCont").eq(parseInt(type)-1).append(html)
					}
					$(".incomeNo").css("display","none");
					$(".income_navCont").eq(parseInt(type)-1).append("<p>系统只保留最近三天的收入明细</p>")
				}else{
					$(".income_navCont").eq(parseInt(type)-1).find("div").remove()
					$(".incomeNo").css("display","block");
					$(".income_details").find("div").eq(0).find("h2").html(0)
					$(".income_details").find("div").eq(1).find("h2").html(0)
					$(".income_details>span>i").html("0=0元")
				}
			},error:function(a){
				
			}
		})
	}else{
		$(".nullNet").css("display","block");
		$(".title").css("display","none");
		$("footer").css("display","none");
		$(".lineTitle").css("display","none");
		$(".cont_title").css("display","none");
	}
}